import 'package:exsun_plate_app/common/constant.dart';
import 'package:flutter/material.dart';

class HomeMap extends StatefulWidget {
  @override
  HomeMapState createState() => new HomeMapState();
}

class HomeMapState extends State<HomeMap> {
  BuildContext context;

  void _goSearch() {
    Navigator.of(context).pushNamed('/SearchPage');
  }

  @override
  Widget build(BuildContext context) {
    this.context = context;
    return Scaffold(
      appBar: PreferredSize(child: AppBar(
          actions: [
            Builder(
              builder: (context) => IconButton(
                icon: Center(
                    child: Image.asset('images/checkcar_map_platform.png')),
                onPressed: () => Scaffold.of(context).openEndDrawer(),
                tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
              ),
            ),
          ],
          elevation: 0,
          backgroundColor: Colors.transparent,
          centerTitle: true,
          title: Text(
            '查车主页',
            style: TextStyle(color: Constants.textColor,fontSize: 16.0),
          )), preferredSize: Size.fromHeight(40)),
      endDrawer: new Drawer(
        child: new Container(
          color: Constants.mainGreenColor,
        ),
      ),
      body: new Container(
        child: Column(
          children: <Widget>[
            new Container(
                margin: EdgeInsets.fromLTRB(10, 0, 10, 10),
                alignment: Alignment.center,
                constraints: BoxConstraints.expand(
                  height: 40,
                ),
                decoration: BoxDecoration(
                  color: Constants.bgColor,
//              shape: BoxShape.rectangle, // 默认值也是矩形
                  borderRadius: new BorderRadius.circular((20.0)),
                ),
                padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                child: TextField(
                  onTap: _goSearch,
                  readOnly: true,
                  decoration: InputDecoration(
                    hintText: '请输入关键字搜索',
                    prefixIcon: Image.asset('images/checkcar_map_search.png'),
                    //这个属性可以控制hintText垂直局中
                    contentPadding: const EdgeInsets.symmetric(vertical: 0.0),
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(0),
                        borderSide: BorderSide.none),
                  ),
                  textInputAction: TextInputAction.done,
                )),
            new Expanded(child: new Container(
              height: 400,
              color: Colors.blue,
            ))
          ],
        ),
      ),
    );
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  void didUpdateWidget(HomeMap oldWidget) {
    super.didUpdateWidget(oldWidget);
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
  }
}
